<?php

class IdeaService{
	
	private $securityKey = 'Vgz$Idea';
	
	public function __construct(){
		$this->init();
	}
	
	public function init() {
		try {
			$this->client = new SoapClient(null, array('location'	=> "http://application.preview.variabele.nl/ZorgbarometerServices/IdeaService.asmx",
													   'uri' 		=> "http://tempuri.org/",
			                                            'trace'     => true));
		} catch (SoapFault $exception) {
			echo "Connectie met Isiz mislukt: ".$exception->getMessage(), $exception->getCode();
		}
		return true;
	}
	
	/**
	 * 
	 * Make a call to the SOAP method addIdea
	 */
	public function callAddIdea(){
		
	}
	
	/**
	 * 
	 * Make a call to the SOAP method getRandomIdea
	 */
	public function callGetRandomIdea(){
		$requestArray = array();
		$requestArray['securityKey'] = $this->securityKey;
		try {
			$randomIdea = $this->client->__soapCall("GetRandomIdea", array('xmlInput'=>new SoapParam($this->securityKey, "securityKey")), array('soapaction' => 'http://tempuri.org/GetRandomIdea'));
		} catch (SoapFault $exception) {
			echo "Random Idea ophalen mislukt: ".$exception->getMessage(), $exception->getCode();
			echo "\n\n";
			print_r($this->client->__getLastRequestHeaders());
			print_r($this->client->__getLastRequest());
		}
		print_r ($randomIdea);
	}
	
	/**
	 * 
	 * Make a call to the SOAP method getTags
	 */
	public function callGetTags(){
		// not implemented yet
	}
	
	/**
	 * 
	 * Make a call to the SOAP method likeIdea
	 */
	
	public function callLikeIdea(){
		
	}
	
}

$ideaService = new IdeaService();
$ideaService->callGetRandomIdea();

